<?php
//活动表

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class StrategyModel extends Model
{
    use HasFactory, SoftDeletes;

// 关注程度：10尝试型，20轻度关注，30中度关注，40重点关注
    const TYPE_SHORT = 1;
    const TYPE_MIDDLE = 2;
    const TYPE_LONG = 3;

    const TYPES = [
        SELF::TYPE_SHORT => '短线',
        SELF::TYPE_MIDDLE => '中长线',
        SELF::TYPE_LONG => '长线',
    ];

    protected $table = 'strategy';

    // 访问器
    protected function successRate(): Attribute
    {
        return new Attribute(
            get: fn ($value) => round($value / 100, 2),
            set: fn ($value) => $value * 100,
        );
    }

    protected function profitPercent(): Attribute
    {
        return new Attribute(
            get: fn ($value) => round($value / 100, 2),
            set: fn ($value) => $value * 100,
        );
    }

}
